home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig11_26.jar
/
Ch11
/
Fig11_26
/
Fig11_26.cpp
Wrap
C/C++ Source or Header
|
1997-11-09
|
696b
|
25 lines
// Fig. 11.26: fig11_26.cpp
// Displaying floating-point values in system default,
// scientific, and fixed formats.
#include <iostream.h>
int main()
{
double x = .001234567, y = 1.946e9;
cout << "Displayed in default format:\n"
<< x << '\t' << y << '\n';
cout.setf( ios::scientific, ios::floatfield );
cout << "Displayed in scientific format:\n"
<< x << '\t' << y << '\n';
cout.unsetf( ios::scientific );
cout << "Displayed in default format after unsetf:\n"
<< x << '\t' << y << '\n';
cout.setf( ios::fixed, ios::floatfield );
cout << "Displayed in fixed format:\n"
<< x << '\t' << y << endl;
return 0;
}